/*
* // +-------------------------------------------------------------------------------------------------
* // |                 有你就好 [ 有节骨乃坚，无心品自端 ]     <http://encoding.wang>
* // +-------------------------------------------------------------------------------------------------
* // |                             独在异乡为异客         每逢佳节倍思亲
* // +-------------------------------------------------------------------------------------------------
* // |                 联系:   <707069100@qq.com>      <http://weibo.com/513778937>
* // +-------------------------------------------------------------------------------------------------
*/

// -----------------------------------------------------------------------------------------------------
// +----------------------------------------------------------------------------------------------------
// |                   ErYang出品 属于小极品          共同学习    共同进步
// +----------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------


package wang.encoding.mroot.common.service


import com.baomidou.mybatisplus.plugins.Page
import com.baomidou.mybatisplus.service.IService


/**
 * 基类 service
 *
 * @author ErYang
 */
interface BaseService<T> : IService<T> {

    /**
     * 查询总数
     *
     * @param whereMap: Map<String, Any>
     * @return T
     */
    fun count(whereMap: Map<String, Any>?): Int?

    // -------------------------------------------------------------------------------------------------

    /**
     * 根据 id 查询 T
     *
     * @param id ID
     * @return T
     */
    fun getById(id: Any): T?

    // -------------------------------------------------------------------------------------------------

    /**
     * 根据 t 对象查询 T
     * @param t 对象
     * @return T
     */
    fun getByModel(t: T): T?

    // -------------------------------------------------------------------------------------------------

    /**
     * 新增 T
     * @param t   T
     *
     * @return Int
     */
    fun save(t: T): Int?

    // -------------------------------------------------------------------------------------------------

    /**
     * 根据 id 删除 T
     * @param id   Any
     *
     * @return Int
     */
    fun removeById(id: Any): Int?

    // -------------------------------------------------------------------------------------------------

    /**
     * 根据 id 批量删除
     * @param idArray   List<Any>
     *
     * @return Int 删除的行数
     */
    fun removeBatchById(idArray: List<Any>): Int?

    // -------------------------------------------------------------------------------------------------

    /**
     * 根据 id 删除(更新状态) T
     * @param t   T
     *
     * @return Int
     */
    fun remove2StatusById(t: T): Int?

    // -------------------------------------------------------------------------------------------------

    /**
     * 根据 id 恢复(更新状态) T
     * @param t   T
     *
     * @return Int
     */
    fun recover2StatusById(t: T): Int?

    // -------------------------------------------------------------------------------------------------

    /**
     * 批量删除(更新状态)
     *
     * @param idArray List<Any>
     * @return Boolean
     */
    fun removeBatch2UpdateStatus(idArray: List<Any>): Boolean?

    // -------------------------------------------------------------------------------------------------

    /**
     * 批量恢复(更新状态)
     *
     * @param idArray List<Any>
     * @return Boolean
     */
    fun recoverBatch2UpdateStatus(idArray: List<Any>): Boolean?

    // -------------------------------------------------------------------------------------------------

    /**
     * 查询 Page 结果集
     *
     * 只有当排序字段有值，排序才会生效
     *
     * @param page   Page<T>
     * @param orderByField   排序字段
     * @param isAsc  是否正序 默认正序
     * @param t   实体类
     * @return Page<T>
     */
    fun list2page(page: Page<T>, t: T, orderByField: String? = "", isAsc: Boolean = true): Page<T>?

    // -------------------------------------------------------------------------------------------------

    /**
     * 得到所有  T 集合
     * @param t  T
     * @return List< T> 集合
     */
    fun listByT(t: T): List<T>?

    // -------------------------------------------------------------------------------------------------

    /**
     * 查询 list 结果集
     *
     * @param whereMap 查询条件集合
     * @param columnArray 查询字段集合
     *
     * @return List<T>
     */
    fun list(whereMap: Map<String, Any>, columnArray: Array<String>?): List<T>?

    // -------------------------------------------------------------------------------------------------

    /**
     * 判断对象的属性值是否唯一
     *
     * 在修改对象的情景下
     * 如果属性新修改的值 value 等于属性原来的值 oldValue 则不作比较
     *
     * @param property 字段
     * @param newValue 新值
     * @param oldValue 旧值
     * @return true (不存在)/false(存在)
     */
    fun propertyUnique(property: String, newValue: Any, oldValue: Any): Boolean

    // -------------------------------------------------------------------------------------------------

    /**
     * 得到最大 sort 值
     *
     * @return Int
     */
    fun getMax2Sort(): Int

    // -------------------------------------------------------------------------------------------------

}

// -----------------------------------------------------------------------------------------------------

// End BaseService interface

/* End of file BaseService.kt */
/* Location: ./src/main/kotlin/wang/encoding/mroot/common/service/BaseService.kt */

// -----------------------------------------------------------------------------------------------------
// +----------------------------------------------------------------------------------------------------
// |                           ErYang出品 属于小极品  O(∩_∩)O~~   共同学习    共同进步
// +----------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------
